|
|
|
|
|
|
|
A variable declared as Public or Global within a BAS module will have an application-wide scope. Public variables may be changed and retrieved from any form or module in the entire application. A value placed in a Public variable will retain its value as long as the program is running. If Public variables are prefaced with the letter g (for Global), you can recognize right away that they have a global scope and will exist as long as the program is running. |
|
|
|
|
| Public Variable Usage 1. Open the Vars.bas file in the sample project by double-clicking it in the Project Explorer window. 2. When you open this file, youll see the following line of code: Public gintCount As Integer |  | After this declaration has been created, you can use that Public variable from anywhere in your program. |
|
|
| Using Global Variables 1. Double-click the Global command button in the form VarExamples.frm. 2. You should see the following code: | | Private Sub cmdGlobal_Click ()
lblGlobal.Caption = gintCount
gintCount = gintCount + 1
End Sub |  | Each time the Global button is clicked, the Caption property of the label is updated to a new value. |
|
|
|